/**************************************************************************************
*
*	Copyright (C) 2010 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	GraphicsResourceManager.h
*
*	Description -	Graphics resource management system.
*
*	Comments	-	
*
*	Modification History:
*			Name			   Date					Description
*			CodeSushi	-	10/25/2010	-	Creation of this file.
**************************************************************************************/

#ifndef _PSX_VERTEX_MANAGER_H_
#define _PSX_VERTEX_MANAGER_H_

#include "PulseSTD.h"
#include "ResourcePool.h"
#include "Texture.h"
#include "VertexDeclaration.h"
#include "VertexBuffer.h"
#include "Singleton.h"
#include "HashTable.h"
#include "GraphicsTypes.h"

namespace Pulse
{

	class GraphicsResourceManager : public Singleton< GraphicsResourceManager >
	{
	public:


		virtual ~GraphicsResourceManager( void );

		virtual EErrorCode::Type Initialize( void );

		virtual void Cleanup( void );

		// Texture management methods
		/////////////////////////////
		Texture * CreateTexture( const CHAR *pName, UINT width = 512, UINT height = 512, 
			ETextureType::Type type = ETextureType::_2D, ETextureUsage::Type usage = ETextureUsage::NORMAL,
			ETextureFormat::Type format = ETextureFormat::A8R8G8B8, UINT depth = 1 );

		Texture * CreateTextureFromFile( const CHAR *pFilename, ETextureType::Type type = ETextureType::_2D, 
			ETextureUsage::Type usage = ETextureUsage::NORMAL, ETextureFormat::Type format = ETextureFormat::DEFAULT );

		// TODO: Create texture from a script file

		// Vertex declaration management methods
		////////////////////////////////////////
		//VertexDeclaration * CreateVertexDeclaration( const CHAR *pName, VertexElement *pElems, SIZE_T size );
		VertexDeclaration * CreateVertexDecleration( const CHAR *pName );

		// TODO: Create vertex declaration from a script file

		// Vertex buffer management methods
		///////////////////////////////////
		VertexBuffer * CreateVertexBuffer( const CHAR *pName, const VertexBufferDescription *pDesc );

		// TODO: Create vertex buffer from a script file

		// TODO: Index buffer creation methods...

		// Shader resources management
		///////////////////////////////////
		void AddShaderConstantSemantic( ShaderConstantSemantic *pSemantic );

		ShaderConstantSemantic * GetShaderConstantSemantic( const CHAR *pName );

		//void AddShaderConstantType( ShaderConstantType *pDataType );

		//ShaderConstantType * GetShaderConstantType( const CHAR *pName );

	private:

		GraphicsResourceManager( void );

		void CreateVertexDeclarations( void );

	private:
		
		friend Singleton;

		typedef HashTable< String, Shader * > ShaderMap;
		typedef HashTable< String, ShaderConstantSemantic * > SemanticMap;
		typedef HashTable< String, ShaderConstantType * > ConstantTypeMap;

		TextureManager				m_textures;
		VertexDeclarationManager	m_vertexDeclarations;
		VertexBufferManager			m_vertexBuffers;
		// TODO: Add vertex indecies
		SemanticMap					m_semanticMap;
		ConstantTypeMap				m_constantTypeMap;
	};

}

#endif /* _PSX_VERTEX_BUFFER_MANAGER_H_ */